
import db from '@dfeidao/atom-nodejs/db';
import log from '@dfeidao/atom-nodejs/logger/log';
import { IncomingHttpHeaders } from 'http';
interface Message {
	psw: string;
	_id: string;
}

interface IWebResult {
	data: unknown;
	cookie?: {
		[name: string]: string;
	} | null;
	content_type?: string;
	headers?: {
		[key: string]: string;
	};
	attachment?: string;
	redirect?: string;
	status_code?: number;
}

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders): Promise<IWebResult> {
	log('Service begin path:login/zj-000001/s003,action_id:' + action_id);

	log('Service end path:login/zj-000001/s003,action_id:' + action_id);
	const { exec, update } = db.operate(action_id, session_id, '12');
	update('pub_user', {
		_id: message._id
	}, {
			password: message.psw
		});
	const ret = await exec();
	return {
		data: ret
	};
}
